﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="测试注册登录修改密码找回密码.aspx.cs" Inherits="ProjectStudy.test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#btnRegister").click(function () {
                $.ajax({
                    type: "POST",
                    url: "../Ajax/RegisterLoginChangePwdFindPwd.ashx",
                    datatype: "json",
                    data: { action: "register", username: $("#username").val(), pwd: $("#pwd").val(), email: $("#email").val() },
                    success: function (data) {
                        //var datalist = eval(data);
                        var ajaxobj = eval("(" + data + ")");
                        if (ajaxobj.status == 'exist') {
                            alert("账号已存在");
                        }
                        if (ajaxobj.status == 'success') {
                            alert("注册成功");
                        }
                    }
                });
            });

            $("#btnLogin").click(function () {
                $.ajax({
                    type: "POST",
                    url: "../Ajax/RegisterLoginChangePwdFindPwd.ashx",
                    datatype: "json",
                    data: { action: "login", username: $("#username2").val(), pwd: $("#pwd2").val() },
                    success: function (data) {

                        var ajaxobj = eval("(" + data + ")");
                        if (ajaxobj.status == 'usernameOrPwdErr') {
                            alert("账号或密码错误");
                        }
                        if (ajaxobj.status == 'success') {
                            alert("登录成功");
                        }
                    }
                });
            });

            $("#btnChangePwd").click(function () {

                $.ajax({
                    type: "POST",
                    url: "../Ajax/RegisterLoginChangePwdFindPwd.ashx",
                    datatype: "json",
                    data: { action: "changepwd", username: $("#username3").val(), oldpwd: $("#oldpwd3").val(), newpwd: $("#newpwd3").val() },
                    success: function (data) {
                        //alert();
                        var ajaxobj = eval("(" + data + ")");
                        if (ajaxobj.status == 'oldPwdErr') {
                            alert("原密码错误");
                        }
                        if (ajaxobj.status == 'success') {
                            alert("密码修改成功");
                        }
                    }
                });
            });

            $("#btnFindPwd").click(function () {
                $.ajax({
                    type: "POST",
                    url: "../Ajax/RegisterLoginChangePwdFindPwd.ashx",
                    datatype: "json",
                    data: { action: "findpwd", username: $("#username4").val() },
                    success: function (data) {
                        //alert();
                        var ajaxobj = eval("(" + data + ")");
                        if (ajaxobj.status == 'success') {
                            alert("密码找回成功，初始密码为：" + ajaxobj.newPwd + ",请及时修改密码");
                        }
                    }
                });
            });

            $("#btnLogout").click(function () {

                $.ajax({
                    type: "POST",
                    url: "../Ajax/RegisterLoginChangePwdFindPwd.ashx",
                    datatype: "json",
                    data: { action: "logout" },
                    success: function (data) {
                        alert("注销成功");
                        location.href = "登录界面.aspx";//跳转至登录界面
                    }
                });
            });

        });
        

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input  type="text" id="username"/>
    <br />
    <br />
    <input  type="password" id="pwd"/>
    <br />
    <br />
    <input  type="text" id="email"/>
    <br />
    <br />
    <input  type="button" id="btnRegister" value="注册"/>
    <br />
    <br />
    <br />

    <input  type="text" id="username2"/>
    <br />
    <br />
    <input  type="password" id="pwd2"/>
    <br />
    <br />
    <input  type="button" id="btnLogin" value="登录"/>
    <br />
    <br />
    <br />
    <input  type="button" id="btnLogout" value="注销" onclick="return Button1_onclick()" />
    <br />
    <br />
    账　号：
    <input  type="text" id="username3"/>
    <br />
    <br />
    原密码：
    <input  type="password" id="oldpwd3"/>
    <br />
    <br />
    新密码：
    <input  type="password" id="newpwd3"/>
    <br />
    <br />
    
    <input  type="button" id="btnChangePwd" value="修改密码"/>
    <br />
    <br />
    <br />
     账　号：
    <input  type="text" id="username4"/>
    <br />
    <br />
    <input  type="button" id="btnFindPwd" value="找回密码"/>
    </div>
    </form>
</body>
</html>
